Skip to content

Conversation

@JoeGruffins
Copy link
Member

closes #34

@JoeGruffins JoeGruffins marked this pull request as ready for review November 7, 2025 09:04
dcr/loader.go Outdated
tweakedSeed = func() []byte { return applyPass(ts[:]) }
} else {
tweakedSeed = func() []byte { return seed }
tweakedSeed = func() []byte { return applyPass(seed) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tweakedSeed func is kind of ugly now, want to clean this up I think.

dcr/loader.go Outdated
Comment on lines 74 to 82
if len(wd.EncryptedSeedPass) != 0 {
encSeedPass, err := hex.DecodeString(wd.EncryptedSeedPass)
if err != nil {
return nil, fmt.Errorf("unable to decode encrypted seed pass: %v", err)
}
seedPass, err = DecryptData(encSeedPass, params.Pass)
if err != nil {
return nil, fmt.Errorf("unable to decrypt wallet seed pass: %v", err)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there appears to be no way to specify the wallet seed password unless it exists encrypted in the recovery data. Maybe that's intentional, but it doesn't seem all too useful to me (i would expect passwords to not need to be saved with the other seed data, and to only be provided as user input when needed).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i see why, though i'm still not sure i like it.

effectively, the encryption password becomes the required user input. and instead of only needing to recover by seed words, now you must keep all of the auxiliary data around as well for the encrypted password. without it, if you only have your seed words, you will never be able to recover your real wallet seed.

unless the password is always a constant (like it is in the tests), and the only reason this is done is to expand the key using pbkdf2 to 64 bytes. but then why would we encrypt the password...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a feature to restore a wallet from saved data. This was done so that wallet backups could leave out the dcrwallet database, because they say it is too big. So we only save the "walletdata" in cake backups. Without the seed passphrase, if one was provided, we could not restore from the walletdata.

We also have to provide the mnemonic when requested, so we need to have the original seed.

I thought saving the seed as is before modification and saving the passphrase separately is the least complicated solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the seed passphrase different from the passphrase used to unlock the wallet?

except for some potentially far-off compatibility concerns, i'm just not seeing how it's useful to have this saved.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the seed passphrase different from the passphrase used to unlock the wallet?

Yes. The same seed can make different wallets based on some data only you know. So if someone finds your mnemonic I guess, they still can't get your seed.

It's being saved so we can restore from the walletdata file. Would you prefer we saved the altered seed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it's fine if it's intentionally being used to generate different seeds from the same mnemonic, as long as you are really really sure you will never forget the various different passwords. i just find it rather unconventional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah idk its this thing https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#from-mnemonic-to-seed

Looking again it seems to say we always apply the PBKDF2 even with no password. We cant do that with the 15 word seed but I guess we should with the new ones.

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Nov 12, 2025

Now erroring if a passphrase is supplied with 15 words. Also always applying for 12 and 24 word https://github.com/decred/libwallet/compare/f0963c09cf459e0a9b957fffc73b8082e51209dd..d6d973d93d9c069e06e6b3508845b11178928f7d

@JoeGruffins
Copy link
Member Author

@JoeGruffins JoeGruffins merged commit cbfeb71 into decred:master Nov 14, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mnemonic: Add passphrase.

2 participants